var app = new Vue({
    el: "#app",
    data: {
        dateWeek: "日期 星期",
        shiftName: "班组：",
        shiftCount: "上班人数：",
        idleValue: 0,
        producingValue: 10,
        breakdownValue: 0,
        tableOneList: [],
        tableTwoList: [],
        tableThreeList: []
    },
    methods: {
        format(percentage) {
            return `${percentage}%`;
        },
        initData() {
            let url = "http://172.30.27.112:8088";
            // 获取除了表格以为的其他数据
            let headerData = "/report/getHeaderData"
            let tableData = "/report/getTableData"
            this.dateWeek = getCurrentFormattedDate();
            sendAjax("GET", url + headerData, null, (error, response) => {
                let json = JSON.parse(response);
                this.shiftName = json.data.shiftName;
                this.shiftCount = json.data.shiftCount;
                this.idleValue = json.data.idleZsEqpCount;
                this.producingValue = json.data.producingZsEqpCount;
                this.breakdownValue = json.data.breakdownZsEqpCount;
            })

            sendAjax("GET", url + tableData, null, (error, response) => {
                let json = JSON.parse(response);
                this.tableOneList = json.data.table1
                this.tableTwoList = json.data.table2
                this.tableThreeList = json.data.table3
            })
        }
    },
    mounted() {
        this.initData();
        setInterval(() => {
            this.initData();
        }, 5000);
    }
});